<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.42">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000; min-height: 12.0px}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
span.s1 {text-decoration: underline}
span.s2 {color: #0000bf}
span.s3 {color: #606060}
</style>
</head>
<body>
<p class="p1"><b>FFTSubbandFlatness - Spectral flatness, divided into subbands</b></p>
<p class="p2"><br></p>
<p class="p3"><b>#[flatness1, flatness2, ... flatnessN+1] = FFTSubbandFlatness.kr(chain, [cutfreq1, cutfreq2, ... cutfreqN])</b></p>
<p class="p4"><br></p>
<p class="p3">Calculates the spectral flatness measure, in the same manner as [<span class="s1">FFTFlatness</span>], but divides the spectrum into (adjacent, non-overlapping) subbands, so returns separate measures for the different subbands.</p>
<p class="p4"><br></p>
<p class="p3">The <b>cutfreqs</b> parameter must be an array of frequencies. For example, to divide a 44100Hz signal into three subbands we might specify<span class="Apple-converted-space">  </span>[ 5512, 11025 ]<span class="Apple-converted-space">  </span>as the cutfreqs, giving subbands of 0-5512Hz, 5512-11025Hz, and 11025-22050Hz. (Frequencies above the Nyquist frequency are not included. Nor is DC.)</p>
<p class="p4"><br></p>
<p class="p3"><b>cutfreqs</b> can only be specified on initialisation - they can't be modulated.</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3"><b>Examples</b></p>
<p class="p5"><br></p>
<p class="p3">In this example we take a "flat" sound (white noise) and an "unflat" sound (a sawtooth wave) and mix them together bandwise using [<span class="s1">PV_BinWipe</span>]. With the spectrum divided into three bands you should be able to see the results.</p>
<p class="p6"><br></p>
<p class="p7">s.boot;</p>
<p class="p7">b = <span class="s2">Buffer</span>.alloc(s,2048,1);</p>
<p class="p7">c = <span class="s2">Buffer</span>.alloc(s,2048,1);</p>
<p class="p7">(</p>
<p class="p8">x = {</p>
<p class="p8"><span class="s2">var</span> inA, inB, chainA, chainB, chain, vals, cutfreqs;</p>
<p class="p9">//in = LPF.ar(WhiteNoise.ar, MouseX.kr(10,10000, 1));</p>
<p class="p10"><br></p>
<p class="p8">inA = <span class="s2">WhiteNoise</span>.ar;</p>
<p class="p8">inB = <span class="s2">Saw</span>.ar;</p>
<p class="p10"><br></p>
<p class="p8">chainA = <span class="s2">FFT</span>(b.bufnum, inA);</p>
<p class="p8">chainB = <span class="s2">FFT</span>(c.bufnum, inB);</p>
<p class="p10"><br></p>
<p class="p8">chain = <span class="s2">PV_BinWipe</span>(chainA, chainB, <span class="s2">MouseX</span>.kr(-1, 1));</p>
<p class="p10"><br></p>
<p class="p8">vals = <span class="s2">FFTSubbandPower</span>.kr(chain, [300, 500, 1500]);</p>
<p class="p10"><br></p>
<p class="p7">vals[3].poll(10, <span class="s3">"hi "</span>);</p>
<p class="p7">vals[2].poll(10, <span class="s3">"med"</span>);</p>
<p class="p8">vals[1].poll(10, <span class="s3">"low"</span>);</p>
<p class="p10"><br></p>
<p class="p8"><span class="s2">Out</span>.ar(0, <span class="s2">IFFT</span>(chain).dup * 0.2);</p>
<p class="p8">}.play(s);</p>
<p class="p7">)</p>
<p class="p5"><br></p>
<p class="p7">x.free;</p>
<p class="p5"><br></p>
</body>
</html>
